using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.TestDrivens;
using Pixysoft.Framework.Configurations.Core;
using System.IO;

namespace Pixysoft.Framework.Configurations.TestCases
{
    [TestDriven(TestDrivenType.IntegrationTest, "XmlTree")]
    class UnitTest_017_XmlTree
    {
        static IAssert assert = Assert.New(true);

        [TestStart]
        public static bool TestCaseStart()
        {

            return true;
        }

        [TestStop]
        public static void TestCaseStop()
        {
        }

        [TestStateSave]
        public static ITestDrivenDocument TestCaseStateSave()
        {
            return assert.Document;
        }

        [TestCase("Save")]
        public static void TestCase_000_Save()
        {
            Assert.Call(UnitTest_013_XmlNode.TestCase_002_Serialize);

            IXmlNode node = Assert.Cache.Pop<IXmlNode>();

            XmlTree tree = new XmlTree();
            tree.Nodes.Add(node);

            tree.Save();

            string filename = StringHelper.default_config_basepath + StringHelper.default_config_filename;

            assert.IsTrue(File.Exists(filename));
            assert.Write(File.ReadAllText(filename));
        }

        [TestCase("Serialize")]
        public static void TestCase_002_Serialize()
        {
            Assert.Call(UnitTest_013_XmlNode.TestCase_002_Serialize);

            IXmlNode node = Assert.Cache.Pop<IXmlNode>();

            XmlTree tree = new XmlTree();
            tree.Nodes.Add(node);
            tree.Nodes.Add(node);

            assert.Write(tree.SerializeAll());
            assert.Write(tree.SerializeAll(true));

            foreach (string str in tree.Serialize())
            {
                assert.Write(str);
            }

            foreach (string str in tree.Serialize(true))
            {
                assert.Write(str);
            }


        }


    }
}
